package com.ruoyi.carService.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.api.domain.CheckInformation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.api.domain.CheckInformation;
import com.ruoyi.carService.service.ICheckInformationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 审核Controller
 * 
 * @author ruoyi
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/check")
public class CheckInformationController extends BaseController
{
    @Autowired
    private ICheckInformationService checkInformationService;

    /**
     * 查询审核列表
     */
    @RequiresPermissions("carService:check:list")
    @GetMapping("/list")
    public TableDataInfo list(CheckInformation checkInformation)
    {
        startPage();
        List<CheckInformation> list = checkInformationService.selectCheckInformationList(checkInformation);
        return getDataTable(list);
    }

    /**
     * 导出审核列表
     */
    @RequiresPermissions("carService:check:export")
    @Log(title = "审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckInformation checkInformation)
    {
        List<CheckInformation> list = checkInformationService.selectCheckInformationList(checkInformation);
        ExcelUtil<CheckInformation> util = new ExcelUtil<CheckInformation>(CheckInformation.class);
        util.exportExcel(response, list, "审核数据");
    }

    /**
     * 获取审核详细信息
     */
    @RequiresPermissions("carService:check:query")
    @GetMapping(value = "/{ciId}")
    public AjaxResult getInfo(@PathVariable("ciId") Long ciId)
    {
        return success(checkInformationService.selectCheckInformationByCiId(ciId));
    }

    /**
     * 新增审核
     */
    @RequiresPermissions("carService:check:add")
    @Log(title = "审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckInformation checkInformation)
    {
        return toAjax(checkInformationService.insertCheckInformation(checkInformation));
    }

    /**
     * 修改审核
     */
    @RequiresPermissions("carService:check:edit")
    @Log(title = "审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckInformation checkInformation)
    {
        return toAjax(checkInformationService.updateCheckInformation(checkInformation));
    }

    /**
     * 删除审核
     */
    @RequiresPermissions("carService:check:remove")
    @Log(title = "审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ciIds}")
    public AjaxResult remove(@PathVariable Long[] ciIds)
    {
        return toAjax(checkInformationService.deleteCheckInformationByCiIds(ciIds));
    }


    //根据信息发布id查询审核信息
    @RequiresPermissions("carService:check:query")
    @GetMapping("/a/selectByRiId/{riId}")
    public AjaxResult checkInformation(@PathVariable("riId") Long riId) {
        CheckInformation checkInformation = checkInformationService.selectCheckInformationById(riId);
        return success(checkInformation);
    }

}
